/*
 * Copyright (c) 2019. Mikes. All rights reserved.
 *
 * You can contact me with sending email to bWlrZXNfMjAxMkAxNjMuY29t for more information!
 */

package com.climber.android.commonres.ui.dialog

import android.os.Bundle
import android.view.Gravity
import android.view.View
import android.widget.ImageView
import androidx.fragment.app.BaseDialogFragment
import com.climber.android.commonres.helper.onClick
import com.climber.android.commonres.R

/**
 * Created by Mikes at 2019-11-20 14:33
 *
 * 倒计时等待微信，支付宝支付结果弹窗
 */
class WaitingPaymentResultDialog : BaseDialogFragment(){
    companion object {
        fun generate(body: WaitingPaymentResultDialog.() -> WaitingPaymentResultDialog): WaitingPaymentResultDialog {
            return with(WaitingPaymentResultDialog()) {
                body()
            }
        }
    }

    fun create(): WaitingPaymentResultDialog {
        val appDialog = WaitingPaymentResultDialog()

        val bundle = Bundle()
        appDialog.arguments = bundle

        return appDialog
    }

    override fun getLayoutResId(): Int = R.layout.com_dialog_waiting_payment_result

    override fun initView(dialogView: View) {
        val ivDismiss = dialogView.findViewById<ImageView>(R.id.ivDismiss)
        ivDismiss.onClick {
            dismiss()
        }

        dialog?.run {
            setCancelable(false)
            setCanceledOnTouchOutside(false)
        }

        setAnim(R.style.DialogScaleIn)
    }

    override fun initData() {
        val tempArguments = arguments
        if (tempArguments == null) {
            dismiss()
            return
        }
    }

    override fun setLocation(gravity: Int) {
        super.setLocation(Gravity.CENTER)
    }
}